package com.lib.framework.utils

import com.lib.framework.manager.LogManager
import org.json.JSONArray
import org.json.JSONObject

/**
 * json 工具类
 *
 * @author keanbin
 */
class JsonUtil {

    companion object {

        /**
         * 获取 json 对象
         */
        fun getJSONObject(jsonStr: String): JSONObject? {
            try {
                return JSONObject(jsonStr)
            } catch (e: Exception) {
                LogManager.e(JsonUtil::class.qualifiedName, "error", e)
            }
            return null
        }

        /**
         * 获取 json 对象数组
         */
        fun getJSONArray(jsonStr: String): JSONArray? {
            try {
                return JSONArray(jsonStr)
            } catch (e: Exception) {
                LogManager.e(JsonUtil::class.qualifiedName, "error", e)
            }
            return null
        }
    }
}